<template>
  <div
    class="editXuecoo"
    v-loading="loading3"
    element-loading-text="数据加载中。。。。"
    element-loading-spinner="el-icon-loading"
  >
    <div class="addstu-box">
      <div class="title">
        <h1>基本信息</h1>
      </div>
      <div class="addstu-box-contain">
        <el-form
          ref="studentInfoDetail2"
          :rules="fieldRules"
          :inline="true"
          :model="pageData"
          class="demo-form-inline"
        >
          <el-row>
            <el-col :span="24">
              <el-row>
                <el-col :span="3">
                  <i>意向客户：</i>
                </el-col>
                <el-col :span="8">
                  <el-input
                    style="margin-left: -12%;"
                    v-model="pageData.agentName"
                    placeholder="意向客户"
                  ></el-input>
                </el-col>
              </el-row>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-row>
                <el-col :span="6">
                  <i>联系人：</i>
                </el-col>
                <el-col :span="15">
                  <el-input v-model="pageData.contacts" placeholder="联系人"></el-input>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="8">
              <el-row>
                <el-col :span="7">
                  <i>
                    <em style="color:red">*</em> 联系电话：
                  </i>
                </el-col>
                <el-col :span="15">
                  <el-form-item label prop="contactPhone" style="width:100%;">
                    <el-input :disabled="true" v-model="pageData.contactPhone" placeholder="联系电话"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="8">
              <el-row>
                <el-col :span="7">
                  <i>
                    <em style="color:red">*</em> 客户来源：
                  </i>
                </el-col>
                <el-col :span="15">
                  <el-form-item label prop="customerSource" style="width:100%;">
                    <el-select :disabled="true" v-model="pageData.customerSource" placeholder="请选择">
                      <el-option
                        v-for="item in student_data_from_options"
                        :key="item.value"
                        :label="item.value"
                        :value="item.key"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-row>
                <el-col :span="6">
                  <i>备用电话：</i>
                </el-col>
                <el-col :span="15" style="margin-bottom:0;">
                  <el-form-item label prop style="width:100%;">
                    <el-input
                      :disabled="isSpareChange"
                      v-model="pageData.phone1"
                      type="number"
                      @change="spareChange"
                    ></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="8">
              <el-row>
                <el-col :span="7">
                  <i>备用电话2：</i>
                </el-col>
                <el-col :span="15" style="margin-bottom:0;">
                  <el-input
                    :disabled="isSpareChange2"
                    v-model="pageData.phone2"
                    type="number"
                    @change="spareChange2"
                  ></el-input>
                </el-col>
              </el-row>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="2">
              <i>所在地区：</i>
            </el-col>
            <el-col :span="12">
              <el-cascader size="large" :options="options" v-model="selectedOptions"></el-cascader>
            </el-col>
            <el-col :span="8">
              <el-input v-model="pageData.address" placeholder="请输入详细地址"></el-input>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-row>
                <el-col :span="6">
                  <i>客户类型：</i>
                </el-col>
                <el-col :span="15">
                  <el-select
                    :disabled="typeDisabled"
                    v-model="pageData.customerType"
                    placeholder="请选择"
                    @change="typeChange"
                  >
                    <el-option
                      v-for="item in student_type_options"
                      :key="item.value"
                      :label="item.value"
                      :value="item.key"
                    ></el-option>
                  </el-select>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="8">
              <el-row>
                <el-col :span="6">
                  <i>客户进展：</i>
                </el-col>
                <el-col :span="15">
                  <el-select
                    :disabled="selectDisabled"
                    v-model="pageData.customerProgress"
                    placeholder="请选择"
                    @change="progressChange"
                  >
                    <el-option
                      v-for="item in student_progress_options"
                      :key="item.value"
                      :label="item.value"
                      :value="item.key"
                    >{{item.value}}</el-option>
                  </el-select>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="8">
              <el-row>
                <el-col :span="6">
                  <i>行业/职位：</i>
                </el-col>
                <el-col :span="15">
                  <el-input v-model="pageData.industry"></el-input>
                </el-col>
              </el-row>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-row>
                <el-row>
                  <el-col :span="6">
                    <i>关键字：</i>
                  </el-col>
                  <el-col :span="15">
                    <el-input v-model="pageData.keyWord" placeholder="关键字"></el-input>
                  </el-col>
                </el-row>
              </el-row>
            </el-col>
            <el-col :span="8">
              <el-row>
                <el-row>
                  <el-col :span="6">
                    <i>获取方式：</i>
                  </el-col>
                  <el-col :span="15">
                    <el-select :disabled="true" v-model="pageData.allotType" placeholder="请选择">
                      <el-option
                        v-for="item in student_data_from_type_options"
                        :key="item.value"
                        :label="item.value"
                        :value="item.key"
                      >{{item.value}}</el-option>
                    </el-select>
                  </el-col>
                </el-row>
              </el-row>
            </el-col>
            <el-col :span="8">
              <el-row>
                <el-row>
                  <el-col :span="6">
                    <i>城市类型：</i>
                  </el-col>
                  <el-col :span="15" style="margin-top:10px;">
                    <span>{{pageData.cityType}}</span>
                  </el-col>
                </el-row>
              </el-row>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-row>
                <el-col :span="6">
                  <i>性别：</i>
                </el-col>
                <el-col :span="15">
                  <el-radio-group v-model="pageData.sex" style="margin-top:6%">
                    <el-radio label="1">男</el-radio>
                    <el-radio label="2">女</el-radio>
                  </el-radio-group>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="8">
              <el-row>
                <el-col :span="6">
                  <i>年龄：</i>
                </el-col>
                <el-col :span="15">
                  <el-input max="100" min="1" type="number" v-model="pageData.age" placeholder></el-input>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="8">
              <el-row>
                <el-col :span="6">
                  <i>学历:</i>
                </el-col>
                <el-col :span="15">
                  <el-input v-model="pageData.education" placeholder></el-input>
                </el-col>
              </el-row>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-col :span="3">
                <i>客户备注：</i>
              </el-col>
              <el-col :span="21">
                <el-input style="margin-left:-5%" v-model="pageData.customerRemark" type="textarea"></el-input>
              </el-col>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </div>
    <!-- <div class="addstu-box">
      <div class="title">
        <h1>客户信息</h1>
      </div>
      <div class="addstu-box-contain">
    <el-form :inline="true" :model="pageData" class="demo-form-inline">-->

    <!-- <el-row>
            <el-col :span="8">
              <el-row>
                <el-col :span="6">
                  <i>微信：</i>
                </el-col>
                <el-col :span="15">
                  <el-input v-model="pageData.wechat" placeholder></el-input>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="8">
              <el-row>
                <el-col :span="6">
                  <i>QQ：</i>
                </el-col>
                <el-col :span="15">
                  <el-input type="number" v-model="pageData.qq" placeholder></el-input>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="8">
              <el-col :span="6">
                <i>邮箱：</i>
              </el-col>
              <el-col :span="15">
                <el-input v-model="pageData.email" placeholder></el-input>
              </el-col>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-row>
                <el-col :span="6">
                  <i>投资动机：</i>
                </el-col>
                <el-col :span="15">
                  <el-input v-model="pageData.investmentMotive" placeholder></el-input>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="8">
              <el-row>
                <el-col :span="9">
                  <i>可用于投资资金：</i>
                </el-col>
                <el-col :span="12">
                  <el-input type="number" v-model="pageData.investmentFund" placeholder></el-input>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="8">
              <el-row>
                <el-col :span="6">
                  <i>风险偏好：</i>
                </el-col>
                <el-col :span="15">
                  <el-input v-model="pageData.riskPreference" placeholder></el-input>
                </el-col>
              </el-row>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-row>
                <el-col :span="6">
                  <i>意向区域：</i>
                </el-col>
                <el-col :span="15">
                  <el-input v-model="pageData.intentionalRegion" placeholder></el-input>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="8">
              <el-row>
                <el-col :span="6">
                  <i>意向产品：</i>
                </el-col>
                <el-col :span="15">
                  <el-input v-model="pageData.intentionalProduct" placeholder></el-input>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="8">
              <el-row>
                <el-col :span="9">
                  <i>意向合作模式：：</i>
                </el-col>
                <el-col :span="12">
                  <el-input v-model="pageData.intentionalCooperationModel" placeholder></el-input>
                </el-col>
              </el-row>
            </el-col>
    </el-row>-->
    <!-- </el-form>
      </div>
    </div>-->
    <div class="addstu-box">
      <div class="title">
        <h1>签约信息</h1>
      </div>
      <div class="addstu-box-contain">
        <el-form :inline="true" class="demo-form-inline">
          <el-row class="sign-box">
            <el-col :span="8">
              <el-row>
                <el-col :span="6">
                  <i>合同类型：</i>
                </el-col>
                <el-col :span="15">
                  <el-input v-model="AgentSignInfoData.contractType" placeholder></el-input>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="8">
              <el-col :span="7">
                <i>签约款：</i>
              </el-col>
              <el-col :span="15">
                <el-input type="number" v-model="AgentSignInfoData.contractMoney" placeholder></el-input>
              </el-col>
            </el-col>
          </el-row>
          <el-row class="sign-box">
            <el-col :span="8">
              <el-row>
                <el-col :span="6">
                  <i>付款情况：</i>
                </el-col>
                <el-col :span="15">
                  <el-input v-model="AgentSignInfoData.paymentSituation" placeholder></el-input>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="8">
              <el-row>
                <el-col :span="7">
                  <i>待付款时间：</i>
                </el-col>
                <el-col :span="13">
                  <el-date-picker
                    v-model="AgentSignInfoData.paymentDate"
                    type="datetime"
                    placeholder="选择日期时间"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    format="yyyy-MM-dd HH:mm:ss"
                  ></el-date-picker>
                </el-col>
              </el-row>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-col :span="3">
                <i>签约备注：</i>
              </el-col>
              <el-col :span="21">
                <el-input
                  style="margin-left:-5%"
                  v-model="AgentSignInfoData.remark"
                  type="textarea"
                ></el-input>
              </el-col>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </div>
    <KtButton
      :label="$t('action.close')"
      perms="true"
      size="medium"
      style="margin-right: 2%;"
      @click="closeSelectedTag"
    ></KtButton>
    <kt-button
      class="stu-btn"
      :label="$t('action.save')"
      perms="true"
      size="medium"
      :loading="editLoading"
      @click="handleSave()"
    />
  </div>
</template>
<script>
import { hasPermission } from "@/permission/index.js";
import axios from "axios";
import KtButton from "@/views/Core/KtButton";
import api from "@/http/api";
import CrmTable from "@/views/Core/CrmTable";
import { regionDataPlus } from "element-china-area-data";
import { isMobile } from "@/utils/validate";
export default {
  name: "EditXuecoo",
  components: {
    KtButton,
    CrmTable
  },
  data() {
    return {
      disabled: false,
      selectDisabled: false,
      typeDisabled: false,
      loading3:false,
      loading: false,
      pageData: [], //代理商基本信息
      AgentSignInfoData: [], //签约数据
      total: 0,
      currentPage: 1,
      pageSize: 10,
      studentSignInfo2: [],
      //   表单验证
      fieldRules: {
        name: [{ required: true, message: "请输入学生姓名", trigger: "blur" }],
        school: [{ required: true, message: "学校名称", trigger: "blur" }],
        oemAccount: [
          { required: true, message: "请输入学籍号", trigger: "blur" }
        ],
        schoolSystem: [
          { required: true, message: "请输入学生学制", trigger: "blur" }
        ],
        grade: [{ required: true, message: "请输入就读年级", trigger: "blur" }],
        account: [
          { required: true, message: "请输入学生账号", trigger: "blur" }
        ],
        parentName: [
          { required: true, message: "请输入家长姓名", trigger: "blur" }
        ],
        contactPhone: [
          { required: true, message: "请输入联系电话", trigger: "blur" }
        ],
        customerSource: [
          {
            required: true,
            message: "请选择客户来源",
            trigger: "change"
          }
        ]
      },
      //   地区
      options: regionDataPlus,
      selectedOptions: [],
      // 客户跟进数据
      followdata: [],
      columns: [
        { prop: "id", label: "序号", minWidth: 50 },
        { prop: "usernumber", label: "跟进时间", minWidth: 80 },
        { prop: "name", label: "联系人", minWidth: 80 },
        { prop: "OEM", label: "沟通形式", minWidth: 80 },
        { prop: "OEMcategory", label: "客户类型", minWidth: 100 },
        { prop: "role", label: "客户进展", minWidth: 70 },
        { prop: "threeDepartment", label: "下次跟进时间", minWidth: 100 }
      ],
      pageResult: {},
      pageRequest: { pageNum: 1, pageSize: 8 },
      editLoading: false,
      student_data_from_options: [], //来源
      student_type_options: [], //类型
      student_progress_options: [], //进展
      isSpareChange: true,
      isSpareChange2: true,
      checkPhoneNum: Boolean, //判断手机号是否重复
      checkPhoneNum2: Boolean //判断手机号是否重复
    };
  },
  watch: {
    // $route: "getParams"
  },
  beforeMount: function() {},
  methods: {
    hasPerms: function(perms) {
      // 根据权限标识和外部指示状态进行权限判断
      return hasPermission(perms) & !this.disabled;
    },
    current_change: function(currentPage) {
      this.currentPage = currentPage;
    },
    // 获取当前页数据
    get_page_data() {
      this.loading3=true
      this.$api.agent
        .investmentQueryAgentIfo({
          customerId: this.$route.query.id
        })
        .then(res => {
          this.pageData = res.investmentInfo;
          this.pageData = res.investmentInfo;
          this.loading3=false
          if(this.pageData.phone1==null){
            this.pageData.phone1=''
          }
          if(this.pageData.phone2==null){
            this.pageData.phone2=''
          }
          if (this.pageData.phone1=='') {
            this.isSpareChange = false;
          }
          if (this.pageData.phone2==''&&this.isSpareChange) {
            this.isSpareChange2 = false;
          }
          let province = res.investmentInfo.province;
          let city = res.investmentInfo.city;
          let area = res.investmentInfo.area;
          this.selectedOption = [];
          if (province == null && city == null && area == null) {
            this.selectedOptions = [];
          } else if (province == "" && city == null && area == null) {
            this.selectedOptions.push("");
          } else if (province != "" && city == "" && area == null) {
            this.selectedOptions.push(
              "" + JSON.stringify(JSON.parse(res.investmentInfo.province)) + "",
              "" + "" + ""
            );
          } else if (province != "" && city != "" && area == "") {
            this.selectedOptions.push(
              "" + JSON.parse(res.investmentInfo.province) + "",
              "" + JSON.parse(res.investmentInfo.city) + "",
              "" + ""
            );
          } else if (province != "" && city != "" && area != "") {
            this.selectedOptions.push(
              "" + JSON.parse(res.investmentInfo.province) + "",
              "" + JSON.parse(res.investmentInfo.city) + "",
              "" + JSON.parse(res.investmentInfo.area) + ""
            );
          }
          let str = /^[\u4e00-\u9fa5]+$/;
          // if (!str.test(province) && !str.test(city) && !str.test(area)) {
          //   this.selectedOptions.push(
          //     "" + JSON.parse(res.investmentInfo.province) + "",
          //     "" + JSON.parse(res.investmentInfo.city) + "",
          //     "" + JSON.parse(res.investmentInfo.area) + ""
          //   );
          // }
        });
      this.$api.agent
        .investmentQuerySignInfo({
          customerId: this.$route.query.id
        })
        .then(res => {
          this.AgentSignInfoData = res.investmentSignInfo;
        });
    },
    // 检查手机号是否重复
    checkRepeatPhone(phone){
      if(phone!=''){
        this.$api.agent.checkPhone({ phone: phone }).then(res => {
          if (res.result == "1") {
            this.isSpareChange2 = false;
            return true
          } else {
            this.$message.error("备用电话" + res.msg);
            return false;
          }
        });
      }
    },
    handleSizeChange(val) {
      this.pageSize = val;
      this.currentPage = 1;
      this.fetchData(1, val);
      // console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.$api.student
        .studentSignList({
          studentId: this.$route.query.id,
          pageNum: val
        })
        .then(res => {
          (this.listStudentSignInfo = res.listStudentSignInfo),
            this.listStudentSignInfo.forEach(item => {
              if (item.isReturn == 1) {
                item.tuidandis = true;
              } else {
                item.tuidandis = false;
              }
            })((this.total = res.total));
        });
    },
    handleFollow(index, row) {
      this.$emit("handleFollow", { index: index, row: row });
      this.dataForm = Object.assign({}, params.row);
      this.$router.push({ path: "/Follow/AddStudentFollow" });
    },
    handleSave() {
      let data = Object.assign({}, this.info);
      let province = this.selectedOptions[0];
      let city = this.selectedOptions[1];
      let area = this.selectedOptions[2];
      this.pageData.province = province;
      this.pageData.city = city;
      this.pageData.area = area;
      let phone=this.pageData.contactPhone
      let phone1=this.pageData.phone1
      let phone2=this.pageData.phone2
      //如果选择的是空=>提交空字符串
      if(this.pageData.customerType==7){
        this.pageData.customerType=""
      }
      let investmentInfo = Object.assign({}, this.pageData);
      let investmentSignInfo = Object.assign({}, this.AgentSignInfoData);
       // 校验电话跟备用电话是否是一样的
      if(!this.isSpareChange&&this.isSpareChange2){
        if(phone1!=''&&phone2==''){
          if(!isMobile(phone1)){
            this.$message.error("请输入正确的备用1手机号！");
            return
          }
          if(phone ==phone1){
            this.$message.error("联系电话与备用电话不能相同！");
            return  
          }
          this.checkRepeatPhone(phone1)
        }
        if(phone1!=''&&phone2!=''){
          if(isMobile(phone1)&&isMobile(phone2)){
            this.submitEdit()  
          }
        }
        
        if(phone1!=''&&isMobile(phone1)&&phone2==''){
          this.$api.agent.checkPhone({ phone: phone1 }).then(res => {
              if (res.result === 1) {
                this.submitEdit() 
                // this.isSpareChange2 = false;
              } else {
                this.$message.error("备用电话1" + res.msg);
                return false;
              }
            });
        }   
        if(phone1==''&&this.isSpareChange2) {
          this.submitEdit() 
        }
      }else if(!this.isSpareChange&&!this.isSpareChange2){
        if(phone2!=''){
          if (phone ==phone2) {
            this.$message.error("联系电话与备用电话不能相同！");
            return 
          }
          if(phone1 ==phone2){
            this.$message.error("备用电话不能相同！");
            return 
          }
          if(!isMobile(phone2)){
            this.$message.error("请输入正确的备用2手机号！");
            return
          }
          // this.submitTrackingInfo()
        }
        if(phone1==''&&phone2==''){
          this.submitEdit()
        }
        if(phone1!=''&&phone2==''){
          
          if(!isMobile(phone1)){
            this.$message.error("请输入正确的备用1手机号！");
            return
          }
        }
        if(phone1==''&&phone2!=''){
          if(!isMobile(phone1)){
            this.$message.error("请输入正确的备用2手机号！")
            return
          }
        }
        if(phone1!=''&&phone2!=''){
          if(!isMobile(phone2)){
            this.$message.error("请输入正确的备用2手机号！")
            return
          }
          if(!isMobile(phone1)){
            this.$message.error("请输入正确的备用1手机号！")
            return
          }
        }
        if((isMobile(phone1)&&!this.isSpareChange)&&(isMobile(phone2)&&!this.isSpareChange2)){
          this.$api.agent.checkPhone({ phone: phone1 }).then(res => {
            if (res.result == "1") {
              this.isSpareChange2 = false;
            this.$api.agent.checkPhone({ phone: phone2 }).then(res => {
              if (res.result == "1") {
                this.submitEdit() 
                // this.isSpareChange2 = false;
              } else {
                this.$message.error("备用电话2" + res.msg);
                return false;
              }
            });
          } else {
            this.$message.error("备用电话1" + res.msg);
            return false;
          }
          });  
        }
        if(phone1!=''&&isMobile(phone1)&&phone2==''){
          this.$api.agent.checkPhone({ phone: phone1 }).then(res => {
              if (res.result == "1") {
                this.submitEdit() 
                // this.isSpareChange2 = false;
              } else {
                this.$message.error("备用电话1" + res.msg);
                return false;
              }
            });
        }      
      }else if((!this.isSpareChange&&!this.isSpareChange2)||(this.isSpareChange&&this.isSpareChange2)){
        this.submitEdit()
      }else if(this.isSpareChange&&!this.isSpareChange2){
        if(phone1!=''&&phone2!=''&&this.isSpareChange){
          if(!isMobile(phone1)){
            this.$message.error("请输入正确的备用1手机号！");
            return
          }
          if(!isMobile(phone2)){
            this.$message.error("请输入正确的备用2手机号！");
            return
          }
        }
        if(isMobile(phone1)&&isMobile(phone2)){
          this.$api.agent.checkPhone({ phone: phone2 }).then(res => {
          if (res.result == "1") {
           this.submitEdit()  
          } else {
            this.$message.error("备用电话" + res.msg);
            return false;
          }
        });
          
        }   
        if(phone2==''){
            this.submitEdit() 
          }
      }
    }, 
    // 提交修改请求
    submitEdit() {
      this.editLoading = true;
      let data = Object.assign({}, this.info);
      let province = this.selectedOptions[0];
      let city = this.selectedOptions[1];
      let area = this.selectedOptions[2];
      this.pageData.province = province;
      this.pageData.city = city;
      this.pageData.area = area;
      let investmentInfo = Object.assign({}, this.pageData);
      let investmentSignInfo = Object.assign({}, this.AgentSignInfoData);
      this.$refs.studentInfoDetail2.validate(validate => {
        if (validate) {
          this.loading = true;
          this.$api.agent
            .investmentInfoUpdate({ investmentInfo, investmentSignInfo })
            .then(res => {
              if (res.result == 2) {
                this.$message({
                  message: res.msg,
                  type: "error"
                });
                this.loading = false;
              } else {
                this.$message({
                  message: res.msg,
                  type: "success"
                });
                this.loading = false;
                this.editLoading = false;
                this.closeSelectedTag();
              }
            });
        } else {
          this.$message({
            message: "请填写关键字段",
            center: true,
            type: "error"
          });
          this.loading = false;
          this.editLoading = false;
          return false;
        }
      });
    },
    // 输入备用电话
    spareChange(value) {
      if(value==''){
        this.pageData.phone2=value
      }
      let isPhone1 = isMobile(this.pageData.phone1)
      this.isSpareChange2 = true
      if (this.pageData.phone1 == "") {
        return true;
      } else if (!isPhone1) {
        this.$message.error("请输入正确备用1手机号！");
        return false;
      } else if (isPhone1) {
        this.checkRepeatPhone(this.pageData.phone1)
        return true;
      }
    },

    spareChange2() {
      let isPhone2 = isMobile(this.pageData.phone2);
      if (this.pageData.phone2 == "") {
        return true;
      } else if (!isPhone2) {
        this.$message.error("请输入正确备用2手机号！");
        return false;
      } else if (isPhone2) {
        return true;
      }
    },
    // 获取来源
    get_investment_customer_from() {
      this.$api.agent.investment_customer_from().then(res => {
        this.student_data_from_options = res.keyValueList;
      });
    },
    // 获取类型
    get_investment_customer_type() {
      this.$api.agent.investment_customer_type().then(res => {
        this.student_type_options = res.keyValueList;
      });
    },
    // 进展
    get_investment_customer_progress() {
      this.$api.agent.investment_customer_progress().then(res => {
        this.student_progress_options = res.keyValueList;
      });
    },

    isActive(route) {
      return route.path === this.$route.path;
    },
    closeSelectedTag(view) {
      this.$store.dispatch("delVisitedViews", this.$route).then(views => {
        if (this.isActive(this.$route)) {
          const latestView = views.slice(-1)[0];
          if (latestView) {
            this.$router.push(latestView);
          } else {
            this.$router.push("/");
          }
        }
      });
    },
    // 点击客户类型
    typeChange() {
      if (this.pageData.customerType == 6) {
        this.pageData.customerProgress = "7";
      }
    },
    // 点击客户进展
    progressChange() {
      if (this.pageData.customerProgress == 7) {
        this.pageData.customerType = "6";
      }
    },
    // 获取方式
    get_student_data_from_type() {
      this.student_data_from_type_options = JSON.parse(
        localStorage.getItem("investmentDataFromType")
      );
    }
  },
  mounted() {
    this.get_investment_customer_from();
    this.get_page_data();
    this.get_investment_customer_type();
    this.get_investment_customer_progress();
    this.get_student_data_from_type();
  }
};
</script>
<style lang='scss' scoped>
.el-row .el-col {
  margin-left: 0 !important;
}
.container .el-radio-group .el-radio:first-child {
  display: inline-block !important;
}
.addstu-box .el-cascader {
  width: 100% !important;
}
.addstu-box {
  text-align: left;
  width: 90%;
  margin: 20px auto;
  border: 1px solid #e4e7ed;
  padding-bottom: 20px;
  .el-row {
    margin: 0 0 2% 0;
  }
  .el-select {
    width: 100%;
  }
  .title h1 {
    font-size: 20px;
    font-weight: bold;
    padding: 20px;
  }
  .city-title {
    text-align: right;
    float: left;
    font-size: 14px;
    color: #606266;
    line-height: 40px;
    padding: 0 12px 0 0;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }
}
.addstu-box {
  .el-cascader {
    width: 100%;
  }
}
.addstu-box-contain {
  .el-row {
    .el-col i {
      font-style: normal;
      text-align: right;
      float: left;
      font-size: 14px;
      color: #606266;
      line-height: 40px;
      padding: 0 0 0 0;
      -webkit-box-sizing: border-box;
      box-sizing: border-box;
    }
  }
}
</style>
<style lang="scss">
.editXuecoo input::-webkit-outer-spin-button,
.editXuecoo input::-webkit-inner-spin-button {
  -webkit-appearance: none !important;
  margin: 0;
}
.sign-box {
  .el-col:first-child .el-form-item__content {
    width: 60%;
  }
  .el-form-item__content {
    width: 60%;
  }
}
.sign-box {
  .el-table {
    .has-gutter {
      .el-table-column--selection {
        display: none;
      }
    }
  }
}
.editXuecoo .el-form--inline .el-form-item__content {
  width: 100%;
}
.editXuecoo .el-select {
  width: 100%;
}
.editXuecoo .el-form--inline .el-form-item {
  margin-bottom: 0 !important;
}
.editXuecoo .addstu-box-contain {
  margin: 0 auto;
}
</style>


